<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>登录</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" media="all">
	<style type="text/css">
		body{
			background: url(../img/bgh4.jpg) repeat 0px 0px;
		}
	</style>
</head>
<body>
	<div class="container" style="width:960px;">
		<div  style="width:520px;margin-left:auto;margin-right:auto;margin-top:100px;">
			<div class="navbar" style="margin-bottom:0px;">
				<div class="navbar-inner">
				  <a class="brand" href="#">pig书屋管理系统</a>
				</div>
			</div>
			
			<form class="form-horizontal well fm" method="post" action="/admin/adminLogin.action">
				<c:if test="${param.msgcode==10001}">
					<div class="alert alert-error">
					  <button type="button" class="close" data-dismiss="alert">&times;</button>
					  <strong>用户名或密码错误</strong>
					</div>
				</c:if>			  
			  <div class="control-group">
			    <label class="control-label" for="inputEmail">用户名</label>
			    <div class="controls">
			      <input type="text" id="inputEmail" placeholder="Name" name="admin.name">
			    </div>
			  </div>
			  <div class="control-group">
			    <label class="control-label" for="inputPassword">密码</label>
			    <div class="controls">
			      <input type="password" id="inputPassword" placeholder="Password" name="admin.pswd">
			    </div>
			  </div>
			  <div class="control-group">
			    <div class="controls">
			      <button type="button" class="btn">登录</button>
			    </div>
			  </div>
			</form>
		</div>
	</div>
	<!-- 此时以admin为根目录，所以要用../，回到根WebRoot -->
	<!-- 先加jquery，再加bootstrap.min.js -->
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.js"></script>
	<script src="../js/validate/jquery.validate.js"></script>
	<script src="../js/sha.js"></script>
	<script>
    	$(function(){
    		$(".fm").validate({
    			rules:{
    				'admin.name':{
    					required:true
    				},
    				'admin.pswd':{
    					required:true
    				}
    			},
    			messages:{
    				'admin.name':{
    					required:'请输入用户名'
    				},
    				'admin.pswd':{
    					required:'请输入密码'
    				}
    			}
    		});
    		
    		$(".btn").click(function(){
    			if($("#inputPassword").val()!=""){/*阻止空密码被加密*/
	    			$("#inputPassword").val(CryptoJS.SHA1($("#inputPassword").val()));
    			}
    			$(".fm").submit();
    		});
    	});
    	
    	</script>
</body>
</html>